package com.naizhuai.ui.testunit;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.Arrays;
import java.util.List;

/**
 * Created by code_han on 2018/1/25.
 */

public class SimpleTestAdapter extends RecyclerView.Adapter<SimpleTestAdapter.FishViewHolder> {

    private List<String> your_array_list = Arrays.asList(
            "This",
            "Is",
            "An",
            "Example",
            "ListView"

    );
    private LayoutInflater inflater;

    public SimpleTestAdapter(Context context) {
        inflater = LayoutInflater.from(context);
    }

    @Override
    public FishViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new FishViewHolder(inflater.inflate(
                android.R.layout.activity_list_item, parent, false));
    }


    @Override
    public void onBindViewHolder(FishViewHolder holder, int position) {
        holder.tv.setText(your_array_list.get(position));
    }

    @Override
    public int getItemCount() {
        return your_array_list.size();
    }

    class FishViewHolder extends RecyclerView.ViewHolder {

        TextView tv;

        FishViewHolder(View view) {
            super(view);
            tv = (TextView) view.findViewById(android.R.id.text1);
        }
    }
}
